%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/order.variables"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[52]<br />ᐳ: 8, 10, 13, 14, 56, 15, 17, 19<br />2: PgSelect[12], PgSelect[24]<br />ᐳ: Access[34], Access[53]<br />3: Connection[16], PgSelectRows[26]<br />ᐳ: 25, 27, 28<br />4: ConnectionItems[20]<br />ᐳ: 33, 35, 36, 37"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 16, 34, 20, 53, 28, 35, 37<br /><br />ROOT Connectionᐸ12ᐳ[16]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 34, 53<br /><br />ROOT __Item{3}ᐸ20ᐳ[29]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 29, 30, 53, 39<br /><br />ROOT Edge{3}[30]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 40, 53<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[40]<br />1: <br />ᐳ: 41, 54, 55<br />2: PgSelectRows[48]<br />ᐳ: First[47], PgSelectSingle[49]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 49<br /><br />ROOT PgSelectSingle{5}ᐸusersᐳ[49]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect12[["PgSelect[12∈0] ➊<br />ᐸmessages+1ᐳ"]]:::plan
    Object15{{"Object[15∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    ApplyInput17{{"ApplyInput[17∈0] ➊"}}:::plan
    Lambda19{{"Lambda[19∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[56]"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ0.firstᐳ"}}:::plan
    PgSelectInlineApply52["PgSelectInlineApply[52∈0] ➊"]:::plan
    Object15 & ApplyInput17 & Lambda19 & Access8 & PgSelectInlineApply52 --> PgSelect12
    PgSelect24[["PgSelect[24∈0] ➊<br />ᐸmessages(aggregate)ᐳ"]]:::plan
    Object15 & ApplyInput17 & Lambda19 & Access8 --> PgSelect24
    Access13{{"Access[13∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access14{{"Access[14∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access13 & Access14 --> Object15
    Connection16[["Connection[16∈0] ➊<br />ᐸ12ᐳ<br />Dependents: 4"]]:::plan
    PgSelect12 & Access8 --> Connection16
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access8
    Access10{{"Access[10∈0] ➊<br />ᐸ0.orderByᐳ"}}:::plan
    __Value0 --> Access10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access13
    __Value2 --> Access14
    Access10 --> ApplyInput17
    ConnectionItems20[["ConnectionItems[20∈0] ➊<br />Dependents: 3<br />More deps:<br />- Connection[16]"]]:::plan
    First25{{"First[25∈0] ➊"}}:::plan
    PgSelectRows26[["PgSelectRows[26∈0] ➊"]]:::plan
    PgSelectRows26 --> First25
    PgSelect24 --> PgSelectRows26
    PgSelectSingle27{{"PgSelectSingle[27∈0] ➊<br />ᐸmessagesᐳ"}}:::plan
    First25 --> PgSelectSingle27
    First33{{"First[33∈0] ➊<br />More deps:<br />- ConnectionItems[20]"}}:::plan
    Access34{{"Access[34∈0] ➊<br />ᐸ12.cursorDetailsᐳ<br />Dependents: 3"}}:::plan
    PgSelect12 --> Access34
    Last36{{"Last[36∈0] ➊<br />More deps:<br />- ConnectionItems[20]"}}:::plan
    Access53{{"Access[53∈0] ➊<br />ᐸ12.m.joinDetailsFor43ᐳ"}}:::plan
    PgSelect12 --> Access53
    PageInfo23{{"PageInfo[23∈1] ➊<br />More deps:<br />- Connection[16]"}}:::plan
    Access31{{"Access[31∈1] ➊<br />ᐸ16.hasNextPageᐳ<br />More deps:<br />- Connection[16]"}}:::plan
    Access32{{"Access[32∈1] ➊<br />ᐸ16.hasPreviousPageᐳ<br />More deps:<br />- Connection[16]"}}:::plan
    Edge30{{"Edge[30∈3]"}}:::plan
    __Item29[/"__Item[29∈3]<br />ᐸ20ᐳ<br />More deps:<br />- ConnectionItems[20]"\]:::itemplan
    PgCursor39{{"PgCursor[39∈3]<br />More deps:<br />- Access[34]"}}:::plan
    __Item29 & PgCursor39 --> Edge30
    __Item29 --> PgCursor39
    PgSelectSingle40{{"PgSelectSingle[40∈4]<br />ᐸmessagesᐳ"}}:::plan
    __Item29 --> PgSelectSingle40
    List54{{"List[54∈5]<br />ᐸ53,40ᐳ"}}:::plan
    Access53 & PgSelectSingle40 --> List54
    PgClassExpression41{{"PgClassExpression[41∈5]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression41
    First47{{"First[47∈5]"}}:::plan
    PgSelectRows48[["PgSelectRows[48∈5]"]]:::plan
    PgSelectRows48 --> First47
    Lambda55{{"Lambda[55∈5]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda55 --> PgSelectRows48
    PgSelectSingle49{{"PgSelectSingle[49∈5]<br />ᐸusersᐳ"}}:::plan
    First47 --> PgSelectSingle49
    List54 --> Lambda55
    PgClassExpression50{{"PgClassExpression[50∈6]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle49 --> PgClassExpression50
    PgClassExpression51{{"PgClassExpression[51∈6]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression50 o--o PgClassExpression51

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,Access8,Access10,PgSelect12,Access13,Access14,Object15,Connection16,ApplyInput17,Lambda19,ConnectionItems20,PgSelect24,First25,PgSelectRows26,PgSelectSingle27,First33,Access34,Last36,PgSelectInlineApply52,Access53 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo23,Access31,Access32 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item29,Edge30,PgCursor39 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle40 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression41,First47,PgSelectRows48,PgSelectSingle49,List54,Lambda55 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression50,PgClassExpression51 bucket6

